//#define DTA_ADMIN_BASE //moved to dta_admin.dme because of issues with way BYOND handles demo files (9-2-10)
/*
//as you can see, you can extend to the system quite easily
dta_admin/admin
	var
		activity = 0
	Login(client/C)
		. = ..()
		activity = -1
	Logout(client/C)
		activity = world.realtime
		return ..()
*/

#define DTA_ADMIN_BASE
#define DTA_ADMIN_EXTENDED

dta_admin/dta_admin/New()
	. = ..()
	if(!admins || !admins.len)
		admins = new/list()

client
	New()
		. = ..()
		spawn(6)
			if(!dta_admin && global.dta_admin && (!address || address == world.address))
				var/dta_admin/admin/A = new(ckey)
				A.access = list("superadmin")
				global.dta_admin.admins += A
				dta_admin = A
				dta_admin.Login(src)
				src << "<tt>An admin record has been created for you with the \"superadmin\" access level.</tt>"

dta_admin/module
	trap
		name = "It's a trap!"
		var/unstuck = 0
		create_tab(mob/M)
			var/L = list2params(list(
				"parent" = skinid,
				"type" = "browser",
				"size" = "0x0",
				"pos" = "0,0",
				"anchor1" = "0,0",
				"anchor2" = "100,100"
			))
			winset(M, "[skinid].browser", L)
		refreshWindow(mob/M)
			. = {"
			<html>
				<head>
					<style type="text/css">
						body {
							font-family: verdana;
							font-size: 12px;
						}
						a { color: #0000FF; }
					</style>
				</head>
				<body>"}
			if(unstuck)
				. += {"You're free to go!"}
			else . += {"
					Great... you're stuck here now!<br />
					Click <a href="byond://?src=\ref[src];cmd=unstuck">here</a> to be freed."}
			. += {"
				</body>
			</html>"}
			M << output(., "[skinid].browser")
		Exit() return unstuck
		Command(href, href_list[])
			if(href_list["cmd"] == "unstuck")
				unstuck = 1
				refreshWindow(usr)
	access
		name = "Only the \"admin\" group can see me."
		access = list("admin")
		create_tab(mob/M)
			var/L = list2params(list(
				"parent" = skinid,
				"type" = "browser",
				"size" = "0x0",
				"pos" = "0,0",
				"anchor1" = "0,0",
				"anchor2" = "100,100"
			))
			winset(M, "[skinid].browser", L)
		refreshWindow(mob/M)
			. = {"
			<html>
				<head>
					<style type="text/css">
						body {
							font-family: verdana;
							font-size: 12px;
						}
						a { color: #0000FF; }
					</style>
				</head>
				<body>
					Hello, admin!
				</body>
			</html>"}
			M << output(., "[skinid].browser")